//
//  KLShoppingListController.m
//  KLShoppingList
//
//  Created by apple on 2017/8/16.
//  Copyright © 2017年 NetEaseExam. All rights reserved.
//

//说明：
//完成 cell ①选中②取消选中③删除后   ④统计
//完成 tax ⑤打开关闭 所有功能实现
//KLHouseCell 每个仓库cell
//KLGoodCell 单个物品cell
//KLAccountCell 每个仓库统计cell
//KLAccountView 购物车统计cell

#import "KLShoppingListController.h"

#import "KLConfig.h"

#import "KLGoodModel.h"
#import "KLHouseModel.h"

#import "KLGoodCell.h"
#import "KLHouseCell.h"
#import "KLAccountCell.h"

#import "KLAccountView.h"
#import "ViewController.h"


@interface KLShoppingListController ()<KLHouseCellDelegate,KLGoodCellDelegate,KLAccountViewDelegate>

@property (nonatomic, strong) NSArray *infos;//所有模型数组
@property (nonatomic, assign) BOOL allIsChoosed;//所有物品是否选中
@property (nonatomic, assign) NSUInteger totalChoosedCount;
@property (nonatomic, assign) CGFloat totalChoosedPrice;
@property (nonatomic, assign) CGFloat totalChoosedTax;
@property (nonatomic, assign) CGFloat totalChoosedBenefit;

@property (nonatomic, weak) KLAccountView *settleAccountsView;

@end

@implementation KLShoppingListController

#pragma mark - data所有数组
- (NSArray *)infos{
    if (_infos == nil) {
        _infos = [NSArray array];
        
        NSArray *dataArr = @[
                   @{
                       @"house":@"杭州保税1号发货仓",
                       @"goods":@[
                               @{
                                   @"image":@"2f1.jpg",
                                   @"title":@"Swisse睡眠片 改善睡眠缓解压 力100粒装 Swisse睡眠片 改善睡眠缓解压 力100粒装 Swisse睡眠片 改善睡眠缓解压 力100粒装 Swisse睡眠片 改善睡眠缓解压 力100粒装",
                                   @"price":@125.00,
                                   @"amount":@1,
                                   @"tax":@12.00,
                                   @"benefit":@0.00,
                                   },
                               @{
                                   @"image":@"2f2.jpg",
                                   @"title":@"Swisse睡眠片 改善睡眠缓解压力 200粒装",
                                   @"price":@125.00,
                                   @"amount":@1,
                                   @"tax":@10.00,
                                   @"benefit":@2.00,
                                   },
                               @{
                                   @"image":@"2f3.jpg",
                                   @"title":@"Swisse睡眠片 改善睡眠缓解压力 300粒装",
                                   @"price":@125.00,
                                   @"amount":@1,
                                   @"tax":@0.00,
                                   @"benefit":@6.00,
                                   },
                               @{
                                   @"image":@"2f4.jpg",
                                   @"title":@"Swisse睡眠片 改善睡眠缓解压力 400粒装",
                                   @"price":@125.00,
                                   @"amount":@1,
                                   @"tax":@0.00,
                                   @"benefit":@8.00,
                                   },
                               @{
                                   @"image":@"2f5.jpg",
                                   @"title":@"Swisse睡眠片 改善睡眠缓解压力 500粒装",
                                   @"price":@125.00,
                                   @"amount":@1,
                                   @"tax":@0.00,
                                   @"benefit":@7.00,
                                   },
                               @{
                                   @"image":@"2f6.jpg",
                                   @"title":@"2件装|STREAMLAND新溪岛Lemon honey柠檬蜜500g/瓶 2",
                                   @"price":@156.00,
                                   @"amount":@2,
                                   @"tax":@14.20,
                                   @"benefit":@0.00,
                                   }
                               ]
                       },
                   
                   @{
                       @"house":@"杭州保税5号发货仓",
                       @"goods":@[
                               @{
                                   @"image":@"2f7.jpg",
                                   @"title":@"2件装笔墨组合 恒星系列尖时尚钢笔 星光紫+黑",
                                   @"price":@22.00,
                                   @"amount":@1,
                                   @"tax":@10.00,
                                   @"benefit":@5.00,
                                   },
                               ]
                       },
                   
                   @{
                       @"house":@"杭州保税13号发货仓",
                       @"goods":@[
                               @{
                                   @"image":@"2f8.jpg",
                                   @"title":@"Swisse睡眠片 改善睡眠缓解压 力100粒装",
                                   @"price":@1250.00,
                                   @"amount":@1,
                                   @"tax":@0.00,
                                   @"benefit":@0.00,
                                   },
                               @{
                                   @"image":@"2f9.jpg",
                                   @"title":@"2件装|STREAMLAND新溪岛Lemon honey柠檬蜜500g/瓶 2",
                                   @"price":@1560.00,
                                   @"amount":@2,
                                   @"tax":@14.20,
                                   @"benefit":@1.00,
                                   }
                               ]
                       },
                   ];
        
        NSMutableArray *models = [NSMutableArray array];
        for (NSDictionary *dict in dataArr) {
            KLHouseModel *model = [KLHouseModel houseWithDict:dict];
            [models addObject:model];
        }
        _infos = [models mutableCopy];
    }
    return _infos;
}

#pragma mark - vc life cycle 控制器生命周期
- (void)viewDidLoad {
    [super viewDidLoad];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    [self setupNav];
    
    [self setupBottom];
    
    [self registerCell];
}

#pragma mark - register cell
- (void)registerCell{
    [self.tableView registerNib:[UINib nibWithNibName:@"KLGoodCell" bundle:nil] forCellReuseIdentifier:good_reuse_id];
    [self.tableView registerNib:[UINib nibWithNibName:@"KLAccountCell" bundle:nil] forCellReuseIdentifier:account_reuse_id];
    [self.tableView registerClass:[KLHouseCell class] forHeaderFooterViewReuseIdentifier:house_reuse_id];
}

#pragma mark - set up bottom 底部统计视图
- (void)setupBottom{
//    id topGuide = self.topLayoutGuide;
//    id bottomGuide = self.bottomLayoutGuide;
//    UITableView *tableView = self.tableView;
//    NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings (topGuide, tableView, bottomGuide);
//    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topGuide]-0-[tableView]-100-[bottomGuide]" options:0 metrics:nil views:viewsDictionary]];
//    [self.view layoutSubviews];

    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, settel_accounts_view_height - section_gap_height, 0);
    
    KLAccountView *bottomView = [KLAccountView totalAccountView];
    bottomView.frame = CGRectMake(0, self.view.frame.size.height-settel_accounts_view_height, self.view.frame.size.width, 60);
    [[UIApplication sharedApplication].windows.lastObject addSubview:bottomView];
    bottomView.delegate = self;
    self.settleAccountsView = bottomView;
}

#pragma mark - set up nav 控制器导航栏
- (void)setupNav{
    //编辑按钮
    UIButton *editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    editBtn.frame = CGRectMake(0, 0, 40, 40);
    editBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [editBtn setTitle:@"编辑" forState:UIControlStateNormal];
    [editBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [editBtn setTitle:@"完成" forState:UIControlStateSelected];
    [editBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateSelected];
    [editBtn setTitle:@"编辑" forState:UIControlStateDisabled];
    [editBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateDisabled];
    [editBtn addTarget:self action:@selector(clickAllEdit:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithCustomView:editBtn];
    
    //消息按钮
    UIBarButtonItem *messageItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"message"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]  style:UIBarButtonItemStylePlain target:self action:@selector(checkNewMessages)];
    
    self.navigationItem.rightBarButtonItems = @[messageItem,editItem];
    
    self.title =@"购物车(0)";
}

- (void)clickAllEdit:(UIButton *)editBtn{
    NSLog(@"编辑菜单");
    editBtn.selected=!editBtn.selected;
}

- (void)checkNewMessages{
    NSLog(@"最新消息");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.infos.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    KLHouseModel *houseModel = self.infos[section];
    //为了清除accout浮动，将account放在cell中
    return houseModel.goods.count+1;
}


#pragma mark - cell&section view
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    KLHouseModel *house = self.infos[indexPath.section];
    if (indexPath.row == house.goods.count) {
        KLAccountCell *accountCell = [KLAccountCell cellWithTableView:tableView];
        accountCell.sectionIndex = indexPath.section;
        accountCell.houseModel = house;
        return accountCell;
    }else{
        KLGoodCell *cell = [KLGoodCell cellWithTableView:tableView];
        KLGoodModel *good = house.goods[indexPath.row];
        cell.goodModel = good;
        cell.delegate = self;
        return cell;
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    KLHouseCell *sectionHeader = [KLHouseCell cellWithTableView:tableView];
    sectionHeader.sectionIndex = section;
    KLHouseModel *house = self.infos[section];
    sectionHeader.houseModel = house;
    sectionHeader.delegate = self;
    return sectionHeader;
}

//- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
//    
//}

//- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
//    KLHouseModel *houseModel = self.infos[section];
//    return houseModel.house;
//}

//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    return 200;
//}

//- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath{
//    return YES;
//}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击了cell");
//    ViewController *vc = [[ViewController alloc] init];
//    [self.navigationController pushViewController:vc animated:YES];
}

- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath{
    return NO;
}

#pragma mark - cell&scetion height
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section{
    return 42.0f;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    KLHouseModel *house = self.infos[indexPath.section];
    if (indexPath.row == house.goods.count) {
        return 72.0f;
    }else{
        KLGoodModel *good = house.goods[indexPath.row];
        return good.openTaxDetail?106.0f:76.0f;
    }
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section{
    return section_gap_height;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    KLHouseModel *house = self.infos[indexPath.section];
    if (indexPath.row == house.goods.count) {
        return 72.0f;
    }else{
        KLGoodModel *good = house.goods[indexPath.row];
        return good.openTaxDetail?106.0f:76.0f;
    }
//    KLGoodCell *cell = [KLGoodCell cellWithTableView:tableView];
////    KLHouseModel *house = self.infos[indexPath.section];
////    KLGoodModel *good = house.goods[indexPath.row];
////    cell.goodModel = good;
//    //计算高度方法1 手动计算 略
//    //计算高度方法2 autoLayOut
//    CGSize size = [cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
//    return size.height;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 42.0f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return section_gap_height;
}



- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
    
}  // called on finger up as we are moving

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    
    
}

#pragma mark - delete cell 删除单个商品
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
    KLHouseModel *house = self.infos[indexPath.section];
    if (indexPath.row == house.goods.count) {
        return NO;
    }else{
        return YES;
    }
}

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
    KLHouseModel *house = self.infos[indexPath.section];
    if (indexPath.row == house.goods.count) {
        return @"222222";
    }else{
        return @"删除";
    }
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    //数据源删除
    KLHouseModel *house = self.infos[indexPath.section];
    NSMutableArray *newGoods = [house.goods mutableCopy];
    [newGoods removeObjectAtIndex:indexPath.row];
    if (newGoods.count>0) {
        house.goods = newGoods;
        [self reloadShoppingList];
        
        //视图删除
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }else{
        NSMutableArray *newInfos = [self.infos mutableCopy];
        [newInfos removeObjectAtIndex:indexPath.section];
        self.infos = newInfos;
        
        [self reloadShoppingList];
        
        //视图删除
        NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:indexPath.section];
        [tableView deleteSections:indexSet withRowAnimation:UITableViewRowAnimationFade];
    }
}

#pragma mark - <KLGoodCellDelegate> 操作商品回调
- (void)goodSelected:(KLGoodCell *)cell{
    //取出选中或取消选中的cell的indexPath
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    KLHouseModel *house = self.infos[indexPath.section];
    KLGoodModel *good = house.goods[indexPath.row];
    good.goodIsChoosed = !good.goodIsChoosed;
    
    //点击单个的时候，判断商品是否选择
    __block NSInteger choosedCount = 0;
    [house.goods enumerateObjectsUsingBlock:^(KLGoodModel *obj, NSUInteger idx, BOOL * _Nonnull stop) {
        // 统计当前house选中goods数量
        if (obj.goodIsChoosed) {
            choosedCount++;
        }
    }];
    if (choosedCount == house.goods.count) {
        house.houseIsChoosed = YES;
    }else{
        house.houseIsChoosed = NO;
    }
    
    house.houseCount = [self countHouseChoosedNumber:indexPath.section];
    house.housePrice = [self countHouseChoosedPrice:indexPath.section];
    house.houseTax = [self countHouseChoosedTax:indexPath.section];
    house.houseBenefit = [self countHouseChoosedBenefit:indexPath.section];
    
    [self reloadShoppingList];
    
    //刷新两个cell
    NSUInteger goodsCount = house.goods.count;
    NSIndexPath *indexPath2 =[NSIndexPath indexPathForRow:goodsCount inSection:indexPath.section];
    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,indexPath2, nil] withRowAnimation:UITableViewRowAnimationFade];
//    //刷新一个section
//    NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:indexPath.section];
//    [self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];
}

- (void)goodTaxDetail:(KLGoodCell *)cell{
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    KLHouseModel *house = self.infos[indexPath.section];
    KLGoodModel *good = house.goods[indexPath.row];
    good.openTaxDetail = !good.openTaxDetail;
    //刷新1个cell
    if (good.openTaxDetail == YES) {
        NSLog(@"打开了税费信息详情");
    }else{
        NSLog(@"关闭了税费信息详情");
    }
    
    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationFade];
}

#pragma mark - <KLHouseCellDelegate> 操作仓库回调
- (void)houseSelected:(NSUInteger)sectionIndex{
    KLHouseModel *house = self.infos[sectionIndex];
    house.houseIsChoosed = !house.houseIsChoosed;
    [house.goods enumerateObjectsUsingBlock:^(KLGoodModel *obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.goodIsChoosed = house.houseIsChoosed;
    }];
    
    house.houseCount = [self countHouseChoosedNumber:sectionIndex];
    house.housePrice = [self countHouseChoosedPrice:sectionIndex];
    house.houseTax = [self countHouseChoosedTax:sectionIndex];
    house.houseBenefit = [self countHouseChoosedBenefit:sectionIndex];

    [self reloadShoppingList];
    
    //刷新一个section
    NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:sectionIndex];
    [self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];
}

#pragma mark - KLAccountViewDelegate 全选 结账回调
- (void)settleAccounts:(KLAccountView *)accountView{
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"结账成功" message:@"购物愉快！" preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alert addAction:cancelAction];
    
    [self presentViewController:alert animated:YES completion:nil];
    
}

- (void)allGoodsSelected:(KLAccountView *)accountView isSelected:(BOOL)allChoosed{
    
    for (KLHouseModel *house in self.infos) {
        house.houseIsChoosed = allChoosed;
        for (KLGoodModel *good in house.goods) {
            good.goodIsChoosed = allChoosed;
        }
    }
    [self reloadShoppingList];
    //刷新整个列表
    [self.tableView reloadData];
    
}

- (void)reloadShoppingList{
    //每次点击要统计底部是否全选
    self.allIsChoosed = [self isAllHousesAndGoodsChoosed];
    self.totalChoosedCount = [self countTotalChoosedNumber];
    self.totalChoosedPrice = [self countTotalChoosedPrice];
    self.totalChoosedTax = [self countTotalChoosedTax];
    self.totalChoosedBenefit = [self countTotalChoosedBenefit];
    
    self.settleAccountsView.totalPrice = self.totalChoosedPrice+self.totalChoosedTax-self.totalChoosedBenefit;
    self.settleAccountsView.totalTax =self.totalChoosedTax;
    self.settleAccountsView.totalCount = self.totalChoosedCount;
    self.settleAccountsView.allGoodsIsChoosed = self.allIsChoosed;
    NSString *title = [NSString stringWithFormat:@"购物车(%lu)",(unsigned long)self.totalChoosedCount];
    self.title = title;
}

#pragma mark - count house 统计单个仓库
- (NSUInteger)countHouseChoosedNumber:(NSUInteger)houseIndex{
    KLHouseModel *house = self.infos[houseIndex];
    NSUInteger count = 0;
    for (KLGoodModel *good in house.goods) {
        if (good.goodIsChoosed) {
            count++;
        }
    }
    return count;
}

- (CGFloat)countHouseChoosedPrice:(NSUInteger)houseIndex{
    KLHouseModel *house = self.infos[houseIndex];
    CGFloat price = 0.0f;
    if (house.houseIsChoosed) {
        for (KLGoodModel *good in house.goods) {
            price += good.price.floatValue * good.amount.integerValue;
        }
    }else{
        for (KLGoodModel *good in house.goods) {
            if (good.goodIsChoosed) {
                price += good.price.floatValue * good.amount.integerValue;
            }
        }
    }
    return price;
    
}

- (CGFloat)countHouseChoosedTax:(NSUInteger)houseIndex{
    KLHouseModel *house = self.infos[houseIndex];
    CGFloat tax = 0.0f;
    if (house.houseIsChoosed) {
        for (KLGoodModel *good in house.goods) {
            tax += good.tax.floatValue * good.amount.integerValue;
        }
    }else{
        for (KLGoodModel *good in house.goods) {
            if (good.goodIsChoosed) {
                tax += good.tax.floatValue * good.amount.integerValue;
            }
        }
    }
    return tax;
}

- (CGFloat)countHouseChoosedBenefit:(NSUInteger)houseIndex{
    KLHouseModel *house = self.infos[houseIndex];
    CGFloat benefit = 0.0f;
    if (house.houseIsChoosed) {
        for (KLGoodModel *good in house.goods) {
            benefit += good.benefit.floatValue * good.amount.integerValue;
        }
    }else{
        for (KLGoodModel *good in house.goods) {
            if (good.goodIsChoosed) {
                benefit += good.benefit.floatValue * good.amount.integerValue;
            }
        }
    }
    return benefit;
}


#pragma mark - count total 统计整个购物车
- (BOOL)isAllHousesAndGoodsChoosed{
    NSUInteger count = 0;
    for (KLHouseModel *house in self.infos) {
        if (house.houseIsChoosed) {
            count++;
        }
    }
    
    return count==0 ? NO:(count == self.infos.count);
}

- (NSUInteger)countTotalChoosedNumber{
    NSUInteger count = 0;
    for (KLHouseModel *house in self.infos) {
        for (KLGoodModel *good in house.goods) {
            if (good.goodIsChoosed) {
                count++;
            }
        }
    }
    return count;
}

- (CGFloat)countTotalChoosedPrice{
    CGFloat price = 0.0f;
    for (KLHouseModel *house in self.infos) {
        if (house.houseIsChoosed) {
            for (KLGoodModel *good in house.goods) {
                price += good.price.floatValue * good.amount.integerValue;
            }
        }else{
            for (KLGoodModel *good in house.goods) {
                if (good.goodIsChoosed) {
                    price += good.price.floatValue * good.amount.integerValue;
                }
            }
        }
    }
    return price;
}

- (CGFloat)countTotalChoosedTax{
    CGFloat tax = 0.0f;
    for (KLHouseModel *house in self.infos) {
        if (house.houseIsChoosed) {
            for (KLGoodModel *good in house.goods) {
                tax += good.tax.floatValue * good.amount.integerValue;
            }
        }else{
            for (KLGoodModel *good in house.goods) {
                if (good.goodIsChoosed) {
                    tax += good.tax.floatValue * good.amount.integerValue;
                }
            }
        }
    }
    return tax;
}

- (CGFloat)countTotalChoosedBenefit{
    CGFloat benefit = 0.0f;
    for (KLHouseModel *house in self.infos) {
        if (house.houseIsChoosed) {
            for (KLGoodModel *good in house.goods) {
                benefit += good.benefit.floatValue * good.amount.integerValue;
            }
        }else{
            for (KLGoodModel *good in house.goods) {
                if (good.goodIsChoosed) {
                    benefit += good.benefit.floatValue * good.amount.integerValue;
                }
            }
        }
    }
    return benefit;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
